home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
HENSA
/
MISC
/
SHELL.ARC
/
Shell
/
Sources
/
c
/
Misc
< prev
next >
Wrap
Text File
|
1994-07-14
|
4KB
|
178 lines
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "DeskLib:GFX.h"
#include "DeskLib:Coord.h"
#include "DeskLib:WimpSWIs.h"
#include "DeskLib:Error.h"
#include "Shell.Extra.h"
#define _PLOT_MAX 16384
char Shell_string[ 1 + Shell_stringMAX];
void Shell_ConvertToTextRect( wimp_rect *rect)
{ int y;
rect->min.x = rect->min.x / Shell_TEXTXSIZE;
rect->max.x = rect->max.x / Shell_TEXTXSIZE;
y = rect->min.y;
rect->min.y = ( 0 - rect->max.y) / Shell_TEXTYSIZE;
rect->max.y = ( 0 - y ) / Shell_TEXTYSIZE;
}
void Shell_ConvertToSubRect( wimp_rect *rect, const wimp_rect *bigrect)
{
Shell_MakeGE( rect->min.x, bigrect->min.x);
Shell_MakeGE( rect->min.y, bigrect->min.y);
Shell_MakeLE( rect->max.x, bigrect->max.x);
Shell_MakeLE( rect->max.y, bigrect->max.y);
rect->min.x -= bigrect->min.x;
rect->max.x -= bigrect->min.x + 1;
rect->min.y -= bigrect->min.y;
rect->max.y -= bigrect->min.y + 1;
return;
}
void Shell_ConvertToSubRect2( wimp_rect *rect, wimp_point bigsize)
{
Shell_MakeGE( rect->min.x, 0);
Shell_MakeGE( rect->min.y, 0);
Shell_MakeLE( rect->max.x, bigsize.x);
Shell_MakeLE( rect->max.y, bigsize.y);
rect->max.x -= 1;
rect->max.y -= 1;
return;
}
/*
void Shell_PrintString( const char *s, int x, int y, const Shell_convertpoint convert)
{
x = Shell_ConvertXToScreen( x, convert);
y = Shell_ConvertYToScreen( y, convert);
GFX_Move( x, y-Shell_PIXELYSIZE);
GFX_Write0( (char *) s);
}
*/
/* This is now a macro */
void Shell_RectangleFill( const wimp_rect *rect, Shell_convertpoint convert)
{ wimp_rect rect2 = *rect;
Shell_ConvertRectToScreen( &rect2, convert);
/* OS_Plot expects 16 bit numbers */
Shell_MakeGE( rect2.min.x, -_PLOT_MAX);
Shell_MakeGE( rect2.min.y, -_PLOT_MAX);
Shell_MakeLE( rect2.max.x, _PLOT_MAX);
Shell_MakeLE( rect2.max.y, _PLOT_MAX);
/* the '-Shell_PIXELYSIZE's are to exclude the top and right edges, as in Wimp_ForceRedraw etc. */
GFX_RectangleFill(
rect2.min.x,
rect2.min.y,
rect2.max.x - rect2.min.x - Shell_PIXELYSIZE,
rect2.max.y - rect2.min.y - Shell_PIXELYSIZE
);
}
void Shell_RectangleFill2( int xmin, int ymin, int xmax, int ymax,
const Shell_convertpoint convert)
{
xmin = Shell_ConvertXToScreen( xmin, convert);
ymin = Shell_ConvertYToScreen( ymin, convert);
xmax = Shell_ConvertXToScreen( xmax, convert);
ymax = Shell_ConvertYToScreen( ymax, convert);
/* OS_Plot expects 16 bit numbers */
Shell_MakeGE( xmin, -_PLOT_MAX);
Shell_MakeGE( ymin, -_PLOT_MAX);
Shell_MakeLE( xmax, _PLOT_MAX);
Shell_MakeLE( ymax, _PLOT_MAX);
GFX_RectangleFill( xmin, ymin, xmax-xmin-Shell_PIXELYSIZE, ymax-ymin-Shell_PIXELYSIZE);
}
void Shell_RectangleFill3( int x, int y, int width, int height,
Shell_convertpoint convert)
{
x = Shell_ConvertXToScreen( x, convert);
y = Shell_ConvertYToScreen( y, convert);
/* OS_Plot expects 16 bit numbers */
Shell_MakeGE( x, -_PLOT_MAX);
Shell_MakeGE( y, -_PLOT_MAX);
Shell_MakeLE( x, _PLOT_MAX);
Shell_MakeLE( y, _PLOT_MAX);
GFX_RectangleFill( x, y, width, height);
}
void Shell_ConvertToSubTextRect( wimp_rect *rect, const wimp_rect *bigrect)
{
Shell_MakeGE( rect->min.x, bigrect->min.x);
Shell_MakeGE( rect->min.y, bigrect->min.y);
Shell_MakeLE( rect->max.x, bigrect->max.x);
Shell_MakeLE( rect->max.y, bigrect->max.y);
rect->min.x = (rect->min.x - bigrect->min.x ) / Shell_TEXTXSIZE;
rect->max.x = (rect->max.x - bigrect->min.x -1) / Shell_TEXTXSIZE;
{ int y = rect->min.y;
rect->min.y = ( bigrect->max.y - rect->max.y ) / Shell_TEXTYSIZE;
rect->max.y = ( bigrect->max.y - y - 1 ) / Shell_TEXTYSIZE;
}
return;
}
void Shell_ConvertToSubTextRect2( wimp_rect *rect, wimp_point rectsize)
{
Shell_MakeGE( rect->min.x, 0);
Shell_MakeGE( rect->min.y, 0);
Shell_MakeLE( rect->max.x, rectsize.x);
Shell_MakeLE( rect->max.y, rectsize.y);
rect->min.x = rect->min.x / Shell_TEXTXSIZE;
rect->max.x = (rect->max.x - 1) / Shell_TEXTXSIZE;
{ int y = rect->min.y;
rect->min.y = ( rectsize.y - rect->max.y ) / Shell_TEXTYSIZE;
rect->max.y = ( rectsize.y - y - 1 ) / Shell_TEXTYSIZE;
}
return;
}